<?php
$data = file_get_contents("php://input");
$mywork = json_decode($data, true);
$name = $mywork['name'] ?? '';
$filename = $name.'.json';
echo $filename;
unset($mywork['name']);
if(file_put_contents($filename, json_encode($mywork))){
    echo "JSON file generated successfully.";
} else {
    echo "Failed to generate JSON file.";
}
?>